package com.aigua.user.controller;

import com.aigua.pojo.User;
import com.aigua.user.service.UserService;
import com.aigua.vo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 04 01 08 51
 **/

@RestController
@RequestMapping("/v1/admin/user")
public class UserController {

    @Autowired
    UserService userService;


    /**
     *
     * 登录
     * @RequestBody: （反序列化）将前台传递过来的json字符串转化成对象
     * 前台发起post请求
     * json字符串里面key和对象里面的属性保持一致
     *
     * @param user
     * @return
     */
   @PostMapping("/login")
    public CommonResult login(@RequestBody User user){

       User user1 = userService.login(user);
       return CommonResult.success(user1);

   }
}
